package com.kongxx.wicketstudy.tutorial.user.web;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

import com.kongxx.wicketstudy.tutorial.user.model.User;

public class UsernamePanel extends Panel {
	public UsernamePanel(String id, IModel entryModel) {
		super(id, entryModel);
		Link link = new Link("link") {
			public void onClick() {
				UserView userView = new UserView(getEntry());
				setResponsePage(userView);
			}
		};
		add(link);
		link.add(new Label("username", getEntry().getUsername()));
	}

	private User getEntry() {
		return (User) getModelObject();
	}
}
